#! /bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/setup_udev.sh"
# setup_device "/dev/video_2060s" "0bda" "1376"

# (pytorch) firefly@jetson:~/ws_vision$ v4l2-ctl --list-ctrls -d /dev/video_2060s 
#                      brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
#                        contrast 0x00980901 (int)    : min=0 max=100 step=1 default=35 value=24
#                      saturation 0x00980902 (int)    : min=0 max=100 step=1 default=64 value=64
#                             hue 0x00980903 (int)    : min=-180 max=180 step=1 default=0 value=0
#  white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=1
#                           gamma 0x00980910 (int)    : min=100 max=500 step=1 default=300 value=100
#            power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=1 value=2
#       white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive
#                       sharpness 0x0098091b (int)    : min=0 max=100 step=1 default=80 value=0
#          backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=0 value=0
#                   exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=3
#               exposure_absolute 0x009a0902 (int)    : min=50 max=10000 step=1 default=166 value=166 flags=inactive
#          exposure_auto_priority 0x009a0903 (bool)   : default=0 value=0
#                    pan_absolute 0x009a0908 (int)    : min=-57600 max=57600 step=3600 default=0 value=0
#                   tilt_absolute 0x009a0909 (int)    : min=-43200 max=43200 step=3600 default=0 value=0
#                   zoom_absolute 0x009a090d (int)    : min=0 max=3 step=1 default=0 value=0

DEV="/dev/video_2060s"
v4l2-ctl -d $DEV --set-ctrl=brightness=0
v4l2-ctl -d $DEV --set-ctrl=contrast=24
v4l2-ctl -d $DEV --set-ctrl=saturation=64
v4l2-ctl -d $DEV --set-ctrl=hue=0
v4l2-ctl -d $DEV --set-ctrl=white_balance_temperature_auto=0
v4l2-ctl -d $DEV --set-ctrl=gamma=100
v4l2-ctl -d $DEV --set-ctrl=power_line_frequency=2
v4l2-ctl -d $DEV --set-ctrl=white_balance_temperature=4600
v4l2-ctl -d $DEV --set-ctrl=sharpness=0
v4l2-ctl -d $DEV --set-ctrl=backlight_compensation=1
v4l2-ctl -d $DEV --set-ctrl=exposure_auto=1
v4l2-ctl -d $DEV --set-ctrl=exposure_absolute=50
v4l2-ctl -d $DEV --set-ctrl=exposure_auto_priority=1